layui.define(['YsSubGrid', 'YsMultyFile', 'YsSubGridBtn', 'optimizeSelectOption'], function (exports) {
	"use strict";
	var YsModal = layui.YsModal, object = {
			c: {data:[]}, // 配置项
			f: function (c) { // 数据初始化
				var s = new Date().getTime(),t = this;
				
				if (!c.id) {
					alert('未配置容器ID，请检查');
					return;
				}
				
				t.c.id = c.id ? c.id : 'id_panel';
				t.c.dto = c.dto;
				
				t.c.dto.valueMap = (t.c.dto.valueMap) ? $.parseJSON(JSON.stringify(t.c.dto.valueMap)) : {};
				
				t.c.subGridConfig = c.subGridConfig; // 是否含子列表
				if(c.subGridConfig) {
					t.c.id_panel_sub = 'id_panel_sub_' + s;
					c.subGridConfig.id = t.c.id_panel_sub;
					t.c.subGridConfig = c.subGridConfig;
				}
				if(t.c.dto.subGridConfig2) {
					t.c.id_panel_sub = 'id_panel_sub_' + s;
					t.c.dto.subGridConfig2.id_table_sub = 'id_table_sub_' + s;
					t.c.dto.subGridConfig2.formObj = t;
				}
				
				t.c.id_header = 'id_header_' + s;
				t.c.id_form = 'id_form_' + s;
			},
			load:function () { // 加载表单
				var t = this;
				
				var h = `<form class="layui-form">`
					
				+ `<!-- 顶部【start】 -->`
				+ `<div class="margin_2_0 height_56 line_height_56 width_percent_100 z_index_1000" id="` + t.c.id_header + `">`
					+ `<div class="bg_color_white height_56 left_0 line_height_56 position_fixed top_0 width_percent_100 z_index_1000">`
						+ `<div class="layui-inline" style="margin-left: 10px; vertical-align: middle; height: 56px; line-height: 56px; padding: 2px 0;">`
							+ (t.c.dto['saveBtn'] && t.c.dto['saveBtn']['state'] == 1 ? `<button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="formSubmit" data-action="` + t.c.dto['saveBtn']['pathCommit'] + `" data-id="id_btn_save"><i class="iconfont icon-save"></i>保存</button>` : ``)
							+ (t.c.dto['flowPassBtn'] && t.c.dto['flowPassBtn']['state'] == 1 ? `<button type="button" class="layui-btn" data-filter="flow_pass" data-action="` + t.c.dto['flowPassBtn']['pathCommit'] + `"><i class="iconfont icon-right-btn"></i>流转</button>` : ``)
							+ (t.c.dto['flowRefuseBtn'] && t.c.dto['flowRefuseBtn']['state'] == 1 ? `<button type="button" class="layui-btn layui-btn-warm" data-filter="flow_refuse" data-action="` + t.c.dto['flowRefuseBtn']['pathCommit'] + `"><i class="iconfont icon-left-btn"></i>退回</button>` : ``)
							+ (t.c.dto['flowInitBtn'] && t.c.dto['flowInitBtn']['state'] == 1 ? `<button type="button" class="layui-btn layui-btn-primary layui-border-orange" data-filter="flow_init" data-action="` + t.c.dto['flowInitBtn']['pathCommit'] + `"><i class="iconfont icon-left-double-arrow"></i>驳回</button>` : ``)
							+ (t.c.dto['flowLogBtn'] && t.c.dto['flowLogBtn']['state'] == 1 ? `<button type="button" class="layui-btn layui-btn-primary" data-filter="flow_log"><i class="iconfont icon-time-history"></i>流程跟踪</button>` : ``)
							+ (t.c.dto['deleteBtn'] && t.c.dto['deleteBtn']['state'] == 1 ? `<button type="button" class="layui-btn layui-btn-danger" data-filter="delete" data-action="` + t.c.dto['deleteBtn']['pathCommit'] + `"><i class="iconfont icon-delete"></i>删除</button>` : ``)
						+ `</div>`
					+ `</div>`
				+ `</div>`
				+ `<!-- 顶部【end】 -->`
				
				+ `<!-- 中间【start】 -->`
				+ `<div class="height_percent_100 margin_2_0 padding_2_0 width_percent_100" style="max-height: calc(100vh - 120px); overflow: unset;">`
					+ `<div id="` + t.c.id_form + `" style="background-color: #ffffff; overflow: unset;">`
							+ `<div class="layui-form-item">`;
				for(var i=0;i<t.c.dto.rows.length;i++){
					h += this.loadInput(t.c.dto.rows[i]);
				}
						h += `</div>`
					+ `</div>`;
				if(t.c.subGridConfig) {
					h += `<!-- 自定义子列表 -->`
						+ `<div id="` + t.c.id_panel_sub + `" style="margin: 2px 0;">`
						+ `</div>`;
				} else if(t.c.dto.subGridConfig2) {
					// 初始化工具条
					var toolbarHTML = `<div class="layui-btn-container">`;
					for (var i = 0; i < t.c.dto.subGridConfig2.buttonArr.length; i++) {
						var button = t.c.dto.subGridConfig2.buttonArr[i];
						toolbarHTML += `<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="` + button.event + `"><i class="iconfont ` + button.icon + `"></i>` + button.name + `</a>`;
					}
					toolbarHTML += `</div>`;
					$('#toolbar_in_form').html(toolbarHTML);
					
					// 初始化TPL脚本
					var templetHTML = ``;
					for (var i = 0; i < t.c.dto.subGridConfig2.templetArr.length; i++) {
						var templet = t.c.dto.subGridConfig2.templetArr[i];
						templetHTML += `<script type="text/html" id="` + templet.id + `">`
							+ templet.html
							+ `</script>`;
					}
					$('#id_tpl_templet_script_in_form').html(templetHTML);
					
					h += `<!-- 可配置子列表 -->`
						+ `<div id="` + t.c.id_panel_sub + `" style="margin: 2px 0; background-color: #ffffff;">`
							+ `<table class="layui-hide" id="` + t.c.dto.subGridConfig2.id_table_sub + `" lay-filter="` + t.c.dto.subGridConfig2.id_table_sub + `"></table>`
						+ `</div>`;
				}
				h += `</div>`
				+ `<!-- 中间【end】 -->`;
				
				if(t.c.dto.footer && t.c.dto.footer.show == 1) {
					h += `<!-- 底部【start】 -->`
					+ `<div class="width_percent_100" style="background-color: #f2f2f2; margin: 0; height: 54px; padding: 2px 0; line-height: 54px; position: fixed; bottom: 0; left: 0; z-index: 1000; vertical-align: middle;">`
						+ `<div class="width_percent_100" style="background-color: #ffffff; margin: 0px 0; padding: 2px 0; height: 50px; line-height: 50px; vertical-align: middle;">`
							+ `<div class="layui-inline layui-col-xs3 margin_6_0">`
								+ `<label class="layui-form-label padding_9_0 width_120">流程状态：</label>`
								+ `<div class="layui-input-block height_38 margin_l_120">`
									+ `<input type="text" value="` + t.c.dto.footer.stateFlowName + `" class="layui-input height_38 cannot_edit" readonly="true">`
								+ `</div>`
							+ `</div>`
							+ `<div class="layui-inline layui-col-xs3 margin_6_0">`
								+ `<label class="layui-form-label padding_9_0 width_120">制单人工号：</label>`
								+ `<div class="layui-input-block height_38 margin_l_120">`
									+ `<input type="text" value="` + t.c.dto.footer.createUserId + `" class="layui-input height_38 cannot_edit" readonly="true">`
								+ `</div>`
							+ `</div>`
							+ `<div class="layui-inline layui-col-xs3 margin_6_0">`
								+ `<label class="layui-form-label padding_9_0 width_120">制单人部门：</label>`
								+ `<div class="layui-input-block height_38 margin_l_120">`
									+ `<input type="text" value="` + t.c.dto.footer.createDeptId + `" class="layui-input height_38 cannot_edit" readonly="true">`
								+ `</div>`
							+ `</div>`
							+ `<div class="layui-inline layui-col-xs3 margin_6_0">`
								+ `<label class="layui-form-label padding_9_0 width_120">制单人岗位：</label>`
								+ `<div class="layui-input-block height_38 margin_l_120">`
									+ `<input type="text" value="` + t.c.dto.footer.createRoleName + `" class="layui-input height_38 cannot_edit" readonly="true">`
								+ `</div>`
							+ `</div>`
						+ `</div>`
					+ `</div>`
					+ `<!-- 底部【start】 -->`;
				}
				h += `</form>`
				$('#'+this.c.id).html(h);
				
				this.listenFormItem();
				this.listenBtn();
				
				if(t.c.dto.subGridConfig2) {
					t.c.subGridObj = layui.YsSubGrid.init(t.c.dto.subGridConfig2);
				}
			},
			loadInput: function(objInput) {
				if(objInput.formHidden == 1) {
					return this.loadHidden(objInput);
				} else if(objInput.type == 't_text') {
					return this.loadText(objInput);
				} else if(objInput.type == 't_number') {
					return this.loadNumber(objInput);
				} else if(objInput.type == 't_textarea') {
					return this.loadTextarea(objInput);
				} else if(objInput.type == 't_buttontext') {
					return this.loadButtonText(objInput);
				} else if(objInput.type == 't_buttontext_multy') {
					return this.loadButtonTextMulty(objInput);
				} else if(objInput.type == 't_dropdown') {
					return this.loadDropdown(objInput);
				} else if(objInput.type == 't_dropdown_multy') {
					return this.loadDropdownMulty(objInput);
				} else if(objInput.type == 't_file') {
					return this.loadFileSingle(objInput);
				} else if(objInput.type == 't_file_multy') {
					return this.loadFileMulty(objInput);
				} else if(objInput.type == 't_file2') {
					return this.loadImg(objInput);
				} else if(objInput.type == 't_hypetext') {
					return this.loadHypeText(objInput);
				} else if(objInput.type == 't_checkbox') {
					return this.loadCheckbox(objInput);
				} else if(objInput.type == 't_radio') {
					return this.loadRadio(objInput);
				} else if(objInput.type == 't_year') {
					return this.loadYear(objInput);
				} else if(objInput.type == 't_monthly') {
					return this.loadMonth(objInput);
				} else if(objInput.type == 't_date') {
					return this.loadDate(objInput);
				} else if(objInput.type == 't_datetime') {
					return this.loadDatetime(objInput);
				} else if(objInput.type == 't_time') {
					return this.loadTime(objInput);
				}
			},
			loadHidden:function (objInput) { // 加载文本输入框
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = `<input type="hidden" name="` + objInput.code + `" value="` + value + `">`;
				return str;
			},
			loadText:function (objInput) { // 加载文本输入框
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var tip = objInput.tip ? objInput.tip : '';
				console.log(tip);
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input type="text" name="` + objInput.code + `" value="` + value + `" placeholder="` + tip + `" autocomplete="off" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` class="layui-input height_30 ` + (objInput.stateReadonly == true ? `cannot_edit` : ``) + `" ` + (objInput.stateReadonly == true ? `disabled` : ``) + `>`
							+ (objInput.stateReadonly == true ? ``:`<i style="position: absolute; right: 5px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-close-fill mouse_hover" lay-filter="buttontext_modal_text_clear" colCode="` + objInput.code + `"></i>`)
					+ `</div>`
					+ `</div>`;
				return str;
			},
			loadNumber:function (objInput) { // 加载文本输入框(数字)
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input type="number" name="` + objInput.code + `" value="` + value + `" autocomplete="off" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` class="layui-input height_30 height_30 ` + (objInput.stateReadonly == true ? `cannot_edit` : ``) + `" ` + (objInput.stateReadonly == true ? `disabled` : ``) + `>`
							+ (objInput.stateReadonly == true ? ``:`<i style="position: absolute; right: 5px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-close-fill mouse_hover" lay-filter="buttontext_modal_text_clear" colCode="` + objInput.code + `"></i>`)
					+ `</div>`
					+ `</div>`;
				return str;
			},
			loadTextarea:function (objInput) { // 加载文本区域
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs12 margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<textarea name="` + objInput.code + `" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` class="layui-textarea ` + (objInput.stateReadonly == true ? `cannot_edit` : ``) + `" style="max-height: 60px!important;">` + value + `</textarea>`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadButtonText:function (objInput) { // 加载弹出框（单选）
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
					+ `<input readonly type="text" name="` + objInput.code + `" value="` + value + `" class="layui-input height_30 buttontextwithtwo" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + `>`
					+ (objInput.stateReadonly == true ? ``:`<i style="position: absolute; right: 27px; top:0px; height: 30px; line-height: 30px; width: 20px;" class="layui-icon layui-icon-close-fill mouse_hover" lay-filter="buttontext_modal_radio_clear" modalKey="` + objInput.modalKey + `" colCode="` + objInput.code + `"></i>`)
					+ `<i style="position: absolute; right: 2px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-more cursor_pointer" lay-filter="buttontext_modal_radio" modalKey="` + objInput.modalKey + `" colCode="` + objInput.code + `"></i>`
					+ `</div>`
					+ `</div>`;
				return str;
			},
			loadButtonTextMulty:function (objInput) { // 加载弹出框(多选)
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input readonly type="text" name="` + objInput.code + `" value="` + value + `" class="layui-input height_30 buttontext" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + `>`
							+ `<i style="position: absolute; right: 2px; top:0px; height: 30px; line-height: 30px; width: 25px;" class="layui-icon layui-icon-more" lay-filter="buttontext_modal_checkbox" modalKey="` + objInput.modalKey + `"></i>`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadDropdown:function (objInput) { // 加载下拉框(普通)
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var t = this;
				var str = ``;
				str	+= `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`;
				str		+= `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`;
				str		+= `<div class="layui-input-block margin_l_150 min_height_38">`;
				str			+= `<select  id="` + objInput.code + `" ` + (objInput.stateReadonly == true ? `disabled` : ``) + ` name="` + objInput.code + `" ` + (objInput.stateReadonly == true ? `disabled` : ``) + ` lay-filter="_input_filter_selector_on_form">`;
				
				// 字典数据
				if(objInput.dictKey) {
					var listOption = MAP_DICT[objInput.dictKey];
					for(var i=0;i<listOption.length;i++){
						var option = listOption[i];
						str += `<option value="` + option.value + `" ` + (value == option.value ? `selected` : ``) + `>` + option.name + `</option>`;
					}
				}
				
				str			+= `</select>`;
				str		+= `</div>`;
				str	+= `</div>`;
				return str;
			},
			loadDropdownMulty:function (objInput) { // 加载多选下拉框
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<textarea name="` + objInput.code + `" style="display:none;">` + value + `</textarea>`
							+ `<div id="` + objInput.code + `" data-filter="_dropdown_multy" data-request-path="` + (objInput.dropdownRequestPath ? objInput.dropdownRequestPath : ``) + `"></div>`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadFileSingle:function (objInput) { // 加载附件(单文件)
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				if (objInput.stateReadonly == 1) {
					var str = ``
						+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
							+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + objInput.name + `：</label>`
							+ `<div class="layui-input-block margin_l_150 min_height_38">`
								+ `<input type="hidden" name="` + objInput.code + `" value="` + value + `" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + `>`
								+ `<img style="width: 92px;height: 92px;margin: 0 10px 10px 0;" src="` + (value ? `/static/img/img_file.jpg` : `/static/img/img_add.jpg`) + `">`
								+ `<button type="button" label="` + objInput.code + `" data-event-name="download-file" class="layui-btn layui-btn-xs layui-btn-normal" onclick="ysFormDownloadFile(this);" ` + (value ? `style="display: inline;"`: `style="display: none;"`) + ` title="查看"><i class="layui-icon">&#xe615;</i></button>`
							+ `</div>`
						+ `</div>`;
					return str;
				} else {
					var str = ``
						+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
							+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
							+ `<div class="layui-input-block margin_l_150 min_height_38">`
								+ `<input type="hidden" name="` + objInput.code + `" value="` + value + `" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + `>`
								+ `<img style="width: 92px;height: 92px;margin: 0 10px 10px 0;" label="` + objInput.code + `" src="` + (value ? `/static/img/img_file.jpg` : `/static/img/img_add.jpg`) + `" lay-filter="fileUpload">`
								+ `<button type="button" label="` + objInput.code + `" data-event-name="remove-file" class="layui-btn layui-btn-xs layui-btn-danger" onclick="ysFormRemoveFile(this);" ` + (value ? `style="display: inline;"`: `style="display: none;"`) + ` title="移除"><i class="layui-icon">&#x1006;</i></button>`
								+ `<button type="button" label="` + objInput.code + `" data-event-name="download-file" class="layui-btn layui-btn-xs layui-btn-normal" onclick="ysFormDownloadFile(this);" ` + (value ? `style="display: inline;"`: `style="display: none;"`) + ` title="查看"><i class="layui-icon">&#xe615;</i></button>`
							+ `</div>`
						+ `</div>`;
					return str;
				}
			},
			loadFileMulty:function (objInput) { // 加载附件(多文件)
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				console.log('objInput-', objInput);
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input type="text" name="` + objInput.code + `" value="` + value + `" autocomplete="off" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` class="layui-input height_30 height_30 cannot_edit" readonly data-filter="_filter_input_file_multy" id="id_form_item_` + objInput.code + `" data-source-code="` + objInput.code + `" data-source-type="` + objInput.multyFileSourceType + `" data-source-id="` + objInput.multyFileSourceId + `">`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadImg:function (objInput) { // 加载图片
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				if (objInput.stateReadonly == 1) {
					var str = ``
						+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
							+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
							+ `<div class="layui-input-block margin_l_150 min_height_38">`
								+ `<input type="hidden" name="` + objInput.code + `" value="` + value + `" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + `>`
								+ `<img style="width: 92px;height: 92px;margin: 0 10px 10px 0;" label="` + objInput.code + `" src="` + (value ? value : `/static/img/img_add.jpg`) + `">`
								+ `<button type="button" label="` + objInput.code + `" data-event-name="download-file" class="layui-btn layui-btn-xs layui-btn-normal" onclick="ysFormDownloadFile(this);" ` + (value ? `style="display: inline;"`: `style="display: none;"`) + ` title="查看"><i class="layui-icon">&#xe615;</i></button>`
							+ `</div>`
						+ `</div>`;
					return str;
				} else {
					var str = ``
						+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
							+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
							+ `<div class="layui-input-block margin_l_150 min_height_38">`
								+ `<input type="hidden" name="` + objInput.code + `" value="` + value + `" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + `>`
								+ `<img style="width: 92px;height: 92px;margin: 0 10px 10px 0;" label="` + objInput.code + `" src="` + (value ? value : `/static/img/img_add.jpg`) + `" lay-filter="imgUpload">`
							+ `</div>`
						+ `</div>`;
					return str;
				}
			},
			loadHypeText:function (objInput) { // 加载富文本编辑框
				var str = ``
					+ `<div class="layui-inline layui-col-xs12 margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<textarea id="` + objInput.code + `" name="` + objInput.code + `" lay-filter="hypeTextEditor"></textarea>`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadCheckbox:function (objInput) { // 加载转换框
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input type="hidden" name="` + objInput.code + `" value="` + (value && value == 1 ? 1 : 0) + `">`
							+ `<input type="checkbox" data-name-for-input="` + objInput.code + `" lay-skin="switch" lay-filter="switch_on_form_for_grid" lay-text="是|否" ` + (value && value == 1 ? `checked` : ``) + `>`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadRadio:function (objInput) { // 加载单选框
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var t = this;
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`;

				// 字典数据
				if(objInput.dictKey) {
					var listOption = MAP_DICT[objInput.dictKey];
					console.log(listOption);
					for(var i=0;i<listOption.length;i++){
						var option = listOption[i];
						str += `<input type="radio" name="` + objInput.code + `" value="` + option.value + `" title="` + option.name + `" ` + (value && value == option.value ? `checked` : ``) + `>`;
					}
				}
				str += 	`</div>`;
				str += `</div>`;
				return str;
			},
			loadYear:function (objInput) { // 加载年份（YYYY）
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input readonly type="text" name="` + objInput.code + `" value="` + value + `" class="layui-input height_30 buttontext" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` data-filter="t_year">`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadMonth:function (objInput) { // 加载月份（YYYY-MM）
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input readonly type="text" name="` + objInput.code + `" value="` + value + `" class="layui-input height_30 buttontext" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` data-filter="t_monthly">`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadDate:function (objInput) { // 加载日期（YYYY-MM-DD）
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input readonly type="text" name="` + objInput.code + `" value="` + value + `" class="layui-input height_30 buttontext" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` data-filter="t_date">`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadDatetime:function (objInput) { // 加载日期（YYYY-MM-DD hh:mm:ss）
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input readonly type="text" name="` + objInput.code + `" value="` + value + `" class="layui-input height_30 buttontext" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` data-filter="t_datetime">`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			loadTime:function (objInput) { // 加载时间（hh:mm:ss）
				var value = objInput.code in this.c.dto.valueMap ? this.c.dto.valueMap[objInput.code] : '';
				var str = ``
					+ `<div class="layui-inline layui-col-xs` + (objInput.formLength * 4) + ` margin_r_0">`
						+ `<label class="layui-form-label padding_6_0 width_160 margin_0_0_0_N10">` + (objInput.required == 1 ? `<font class="f_red">*</font>` : ``) + objInput.name + `：</label>`
						+ `<div class="layui-input-block margin_l_150 min_height_38">`
							+ `<input readonly type="text" name="` + objInput.code + `" value="` + value + `" class="layui-input height_30 buttontext" ` + (objInput.required == 1 ? `lay-verify="required"` : ``) + ` data-filter="t_time">`
						+ `</div>`
					+ `</div>`;
				return str;
			},
			listenFormItem: function(modalKey, colCode) {
				var t = this;
				
				// 初始化下拉框(多选)
				var domForm = $('#' + t.c.id_form);
				domForm.find('div[data-filter="_dropdown_multy"]').each(function(index, domEle){
					var id = $(this).attr('id');
					var valueArr = $('textarea[name="' + id + '"]').val();
					console.log(valueArr);
					var JA = $.parseJSON(valueArr ? valueArr : '[]');
					var values = [];
					for (var i = 0; i < JA.length; i++) {
						values.push('' + JA[i].value); // 用字符串的形式
					}
					var requestUrl = $(this).attr('data-request-path');
					xmSelect.render({
						el: '#' + id,
						direction: 'auto',
						paging: false,
						filterable: true,
						toolbar: {
							show: true,
							showIcon: false, // 隐藏图标
							list: [ 'ALL', 'CLEAR']
						},
						remoteSearch: true,
						pageRemote: true,
						remoteMethod: function(val, cb, show, pageIndex){
					        $.post(requestUrl, {
					            name: val
					        }, function(res){
					        	for (var i = 0; i < res.data.length; i++) {
									var resData = res.data[i];
									if (values.indexOf('' + resData.value) >= 0) {
										res.data[i].selected = true;
									} else {
										res.data[i].selected = false;
									}
								}
					        	cb(res.data, 10);
					        });
						},
						on: function(data){
							var arr = [];
							for (var i = 0; i < data.arr.length; i++) {
								var single = data.arr[i];
								arr.push({name: single.name, value: single.value});
							}
							$('textarea[name="' + id + '"]').text(JSON.stringify(arr));
						}
					});
				});
			},
			listenBtn:function () { // 添加监听
				// layui表单渲染，使控件生效
				layui.form.render();
				
				var t = this;
				var domPanel = $('#' + t.c.id);
				var domForm = $('#' + t.c.id_form);
				
				// 监听表单“保存”按钮
				layui.form.on('submit(formSubmit)', function(data){
					var indexOfLoading = layer.load(1, {shade: [0.5,'#000000']});
					
					var commitPath = $('button[data-id="id_btn_save"]').attr('data-action');

					if(t.c.subGridConfig) {
						data.field['subData'] = JSON.stringify(t.getSubData());
					}
					if(t.c.dto.subGridConfig2) {
						data.field['subData'] = JSON.stringify(t.getSubData2());
					}
					$.post(commitPath, data.field, function(res){
						if (res.code == 0) {
							layer.msg('操作成功');
							var dto = res.data;
							setTimeout(function(){
								layer.close(indexOfLoading);
								if(dto == null || dto == undefined) {
									return;
								} else if(dto.code == 0) {
									return;
								} else if(dto.code == 1) {
									// 跳转编辑页
									window.location.href = dto.url;
								} else if(dto.code == 2) {
									
									if (window.parent) {
										// 关闭并刷新父列表
										window.parent.layer.close(parent.layer.getFrameIndex(window.name));
										window.parent.location.reload();
									} else {
										window.location.reload();
									}
								} else if(dto.code == 3) {
									window.location.reload();
								} else if(dto.code == 4) {
									window.top.closeTabActive();
								}	else if(dto.code == 5) {
									window.open(dto.url);
								}
							}, 1000);
						} else {
							layer.close(indexOfLoading);
							layer.alert(res.msg);
						}
					});
					return false;
				});
				
				// 监听“流转”按钮
				domPanel.find('button[data-filter="flow_pass"]').on('click',function (e) {
					var domThis = $(this);
					
					layer.confirm('确定流转？ ', {
							btn: ['确定','取消'] //按钮
						}, function(index){
							var indexOfLoading = layer.load(1, {
								shade: [0.5,'#000000'] //0.1透明度的白色背景
							});
							$.ajax({
								type: "POST",
								url: domThis.attr('data-action'),
								data: {},
								success: function (data) {
									if (data.code == 0) {
										layer.msg(data.msg);
										setTimeout(function(){
											location.reload();
										}, 1000);
									} else {
										alert(data.msg);
									}
									layer.close(indexOfLoading);
								}
							});
						}, function(index){
							layer.close(index);
						}
					);
				});
				
				// 监听“退回”按钮
				domPanel.find('button[data-filter="flow_refuse"]').on('click',function (e) {
					var domThis = $(this);
					layer.prompt({title: '请输入退回原因'}, function(value, index, elem){
						if(value === '') {
							return elem.focus();
						} else {

							var indexOfLoading = layer.load(1, {
								shade: [0.5,'#000000'] //0.1透明度的白色背景
							});
							$.ajax({
								type: "POST",
								url: domThis.attr('data-action'),
								data: {reason: value},
								success: function (data) {
									if (data.code == 0) {
										layer.msg(data.msg);
										setTimeout(function(){
											location.reload();
										}, 1000);
									} else {
										alert(data.msg);
									}
									layer.close(indexOfLoading);
									// 关闭 prompt
									layer.close(index);
								}
							});
						}
					});
					return;
				});
				
				// 监听“驳回”按钮
				domPanel.find('button[data-filter="flow_init"]').on('click',function (e) {
					var domThis = $(this);
					layer.prompt({title: '请输入驳回原因'}, function(value, index, elem){
						if(value === '') {
							return elem.focus();
						} else {

							var indexOfLoading = layer.load(1, {
								shade: [0.5,'#000000'] //0.1透明度的白色背景
							});
							$.ajax({
								type: "POST",
								url: domThis.attr('data-action'),
								data: {reason: value},
								success: function (data) {
									if (data.code == 0) {
										layer.msg(data.msg);
										setTimeout(function(){
											location.reload();
										}, 1000);
									} else {
										alert(data.msg);
									}
									layer.close(indexOfLoading);
									// 关闭 prompt
									layer.close(index);
								}
							});
						}
					});
					return;
				});
				
				// 监听“流程跟踪”按钮
				domPanel.find('button[data-filter="flow_log"]').on('click',function (e) {
		        	var w=($(window).width()*0.9);
		        	var h=($(window).height() - 50);
		            layer.open({
		                type: 2,
		                area: [w+'px', h +'px'],
		                fix: true,
		                maxmin: false,
		                shadeClose: true,
		                shade:0.4,
		                title: "流程跟踪",
		                content: '/web/flow/ysp/toAudit?bid=' + t.c.dto.bid
		            });
				});
				
				// 监听“删除”按钮
				domPanel.find('button[data-filter="delete"]').on('click',function (e) {
					var domThis = $(this);
					layer.confirm('确定删除？ ', {
							btn: ['确定','取消'] //按钮
						}, function(){
							var indexOfLoading = layer.load(1, {
								shade: [0.5,'#000000'] //0.1透明度的白色背景
							});
							$.ajax({
								type: "POST",
								url: domThis.attr('data-action'),
								data: {},
								success: function (data) {
									if (data.code == 0) {
										layer.msg(data.msg);
										setTimeout(function(){
											var domActive = window.top.getDomActive(); // 获取当前页面的节点
											window.top.closeTabByDom(domActive); // 根据节点关闭页面
										}, 1000);
									} else {
										alert(data.msg);
									}
									layer.close(indexOfLoading);
								}
							});
						}, function(){
						}
					);
				});

				// 初始化输入框-清除【start】
				domPanel.find('i[lay-filter="buttontext_modal_text_clear"]').each(function(index, domEle){
					var colCode = $(this).attr('colCode');
					console.log('colCode',colCode);
					var domForm = $('#' + t.c.id_form);
					$(this).on('click',function (e) {
						domForm.find('input[name="' + colCode + '"]').val(null);
						domForm.find('input[name="' + colCode + '"]').trigger("propertychange");
					});


				});
				// 初始化输入框-清除【end】

				// 初始化弹出框【start】
				domPanel.find('i[lay-filter="buttontext_modal_radio"]').each(function(index, domEle){
					var modalKey = $(this).attr('modalKey');
					var colCode = $(this).attr('colCode');
					
					$(this).on('click',function (e) {
						t.showModal(modalKey, colCode);
					});
				});

				// 初始化弹出框【end】

				// 初始化弹出框【start】-清除
				domPanel.find('i[lay-filter="buttontext_modal_radio_clear"]').each(function(index, domEle){
					var modalKey = $(this).attr('modalKey');
					var colCode = $(this).attr('colCode');
					//var t = this;
					var domForm = $('#' + t.c.id_form);
					$(this).on('click',function (e) {
						for(var i = 0; i < t.c.dto.rows.length; i++){
							var col = t.c.dto.rows[i];
							if (col.code == colCode) {
								// 给选择框设置的字段赋值
								domForm.find('input[name="' + colCode + '"]').val(null);
								domForm.find('input[name="' + colCode + '"]').trigger("propertychange");
							} else if(col.modalRelativeCode == colCode) {
								domForm.find('input[name="' + col.code + '"]').val(null);
								domForm.find('input[name="' + col.code + '"]').trigger("propertychange");
							}
						}
					});


				});
				// 初始化弹出框【end】
				
				// 初始化开关
				layui.form.on('switch(switch_on_form_for_grid)', function(data){
					var nameOfInput = $(this).attr('data-name-for-input');
					
					//更改选中和未选中时，传到后台的值，此时选中传1，未选中传0。
					domForm.find('input[name="' + nameOfInput + '"]').val(this.checked ? 1 : 0).trigger('change');
				});
				
				//初始化表单-YYYY
				domPanel.find('input[data-filter="t_year"]').each(function(){
					var nameOfInput = $(this).attr('name');
					//var maxtime = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + (myDate.getDate());
					layui.laydate.render({
						elem: this
						, type: 'year'
						, calendar: true
						, btns: ['clear', 'confirm', 'now']
						, done: function (value, date) {
							//这里时选中后触发事件
							//value是选中的值
							var time = value;
							
							// 同步触发表单变更
							domForm.find('input[name="' + nameOfInput + '"]').trigger('change');
						}
					});
				});
				
				//初始化表单-YYYYMM
				domPanel.find('input[data-filter="t_monthly"]').each(function(){
					var nameOfInput = $(this).attr('name');
					layui.laydate.render({
						elem: this
						, type: 'month'
						, calendar: true
						, btns: ['clear', 'confirm', 'now']
						, done: function (value, date) {
							//这里时选中后触发事件
							//value是选中的值
							var time = value;
							
							// 同步触发表单变更
							domForm.find('input[name="' + nameOfInput + '"]').trigger('change');
						}
					});
				});
				
				//初始化表单-YYYYMMDD
				domPanel.find('input[data-filter="t_date"]').each(function(){
					var nameOfInput = $(this).attr('name');
					var myDate = new Date();
					//var maxtime = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + (myDate.getDate());
					layui.laydate.render({
						elem: this
						, type: 'date'
						//, max: maxtime
						//, max: maxtime//设置选择最大时间为当前
						, calendar: true
						, btns: ['clear', 'confirm', 'now']
						, done: function (value, date) {
							//这里时选中后触发事件
							//value是选中的值
							var time = value;
							
							// 同步触发表单变更
							domForm.find('input[name="' + nameOfInput + '"]').trigger('change');
						}
					});
				});
				
				//初始化表单-日期时间
				domPanel.find('input[data-filter="t_datetime"]').each(function(){
					var nameOfInput = $(this).attr('name');
					var myDate = new Date();
					var maxtime = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + (myDate.getDate()) + " 23:59:59";
					layui.laydate.render({
						elem: this
						, type: 'datetime'
						, max: maxtime
						//, max: maxtime//设置选择最大时间为当前
						, calendar: true
						, btns: ['clear', 'confirm', 'now']
						, done: function (value, date) {
							//这里时选中后触发事件
							//value是选中的值
							var time = value;
							
							// 同步触发表单变更
							domForm.find('input[name="' + nameOfInput + '"]').trigger('change');
						}
					});
				});
				
				//初始化搜索框-时间
				domPanel.find('input[data-filter="t_time"]').each(function(){
					var nameOfInput = $(this).attr('name');
					var myDate = new Date();
					var maxtime = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + (myDate.getDate());
					layui.laydate.render({
						elem: this
						, type: 'time'
						, calendar: true
						, btns: ['clear', 'confirm', 'now']
						, done: function (value, date) {
							//这里时选中后触发事件
							//value是选中的值
							var time = value;
							
							// 同步触发表单变更
							domForm.find('input[name="' + nameOfInput + '"]').trigger('change');
						}
					});
				});
				
				t.listenFormOfImg(); // 添加监听-图片
				t.listenFormOfFileSingle(); // 添加监听-单文件框
				t.listenFormOfFileMulty(); // 添加监听-多文件框
				t.listenFormOfHypeText(); // 添加监听-富文本框
			},
			listenFormOfImg:function () { // 添加监听-图片
				var t = this;
				var domForm = $('#' + t.c.id_form);
				// 初始化图片上传控件
				$('#' + t.c.id).find('img[lay-filter="imgUpload"]').each(function(index, domEle){
					var dom = this;
					var labelName = $(this).attr('label');
					layui.upload.render({
						elem: dom,
						url: t.c.dto.urlUpload,
						multiple: false,
						progress: function(n, elem){
							//dom.val(n + '%');
						},
						done: function(res){
							console.log(res);
							if (res.code == 0) {
								var urlImg = res.data.filePath;
								domForm.find('img[label="' + labelName +'"]').attr('src', urlImg);
								domForm.find('input[name="' + labelName +'"]').val(urlImg);
							}
						}
					});
				})
			},
			listenFormOfFileSingle:function () { // 添加监听-单文件框
				var t = this;
				var domForm = $('#' + t.c.id_form);
				
				// 初始化单文件上传控件
				$('#' + t.c.id).find('img[lay-filter="fileUpload"]').each(function(index, domEle){
					var dom = this;
					var labelName = $(this).attr('label');
					layui.upload.render({
						elem: dom,
						url: t.c.dto.urlUpload,
						multiple: false,
						accept: 'file',
						progress: function(n, elem){
							//dom.val(n + '%');
						},
						done: function(res, index, upload){
							if (res.code == 0) {
								var urlFile = res.data.filePath;
								domForm.find('img[label="' + labelName +'"]').attr('src', '/static/img/img_file.jpg');
								domForm.find('input[name="' + labelName +'"]').val(urlFile);
								domForm.find('button[label="' + labelName +'"]').show();
							}
						}
					});
				});
			},
			listenFormOfFileMulty:function () { // 添加监听-多文件框
				var t = this;
				var domForm = $('#' + t.c.id_form);
				
				// 初始化多文件上传控件
				$('#' + t.c.id).find('input[data-filter="_filter_input_file_multy"]').on('click',function (e) {
					var dom = this;
					
					var btnDisable = t.c.dto['saveBtn']['state'] == 1 ? false : true;
					layui.YsMultyFile.init({dom: dom, btnDisable: btnDisable, extraParam:{usePlace: 'form', parentObj: t}});
				});
			},
			listenFormOfHypeText:function () { // 添加监听-富文本框
				var t = this;
				
				// 初始化富文本
				$('#' + t.c.id).find('textarea[lay-filter="hypeTextEditor"]').each(function(index, domEle){

					var id = $(this).attr('id');

					var url = window.location.href;
					var arrUrl = url.split("//");
					var start = arrUrl[1].indexOf("/");
					var preUrl = 'http://' + arrUrl[1].substring(0, start);
					
					var config = {
						"width": "100%",
						"height": 450,
						"resizeType": 0,
						"autoHeightMode": false,
						"items": [
							'source', '|',
							'undo', 'redo', '|',
							'preview', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|',
							'justifyleft', 'justifycenter', 'justifyright',
							'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'clearhtml', 'quickformat', 'selectall', '/',
							'formatblock', 'fontname', 'fontsize', '|',
							'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
							'image', 'multiimage', 'insertfile', 'link', 'unlink'
						],
						"allowImageRemote": false,
						"uploadJson": preUrl + "/api/outer/upload/uploadfileForEditor",
						"filePostName": "fileStream",
						"formatUploadUrl": false,
						afterBlur: function () {
							this.sync();
						}
					};
					var editor = KindEditor.create('#' + id, config);
					
					var code = $(this).attr('name');
					for(var i=0;i<t.c.dto.rows.length;i++){
						var col = t.c.dto.rows[i];
						if(col.code == code) {
							editor.html(col.value);
							break;
						}
					}
					editor.sync();
				});
			},
			showModal: function(modalKey, colCode) {
				var t = this;
				
				// 打开单选框,
				layui.YsModal.init({modalKey: modalKey, colCode: colCode, parentObj: t, extraData:{}, conditionsDefault: [{code: 'aaa', value:'123'},{code: 'bbb', value:'456'}], sameCode: 'xx', pathGridRequest: ''});
				
				// 打开复选框
				//layui.YsModal.init({modalKey: modalKey, type: 'checkbox', uniqueKey: 'id', parentObj: t, selectedData: [{'id': 1}]}, extraData:{}, conditionsDefault: [{code: 'aaa', value:'123'},{code: 'bbb', value:'456'}], sameCode: 'xx', pathGridRequest: ''});
			},
			matchValuesAfterModalSelectRadio:function (colCode, rowSelected, extraData) { // 单选框选中数据后，匹配表单数值
				var t = this;
				var domForm = $('#' + t.c.id_form);

				for(var i = 0; i < t.c.dto.rows.length; i++){
					var col = t.c.dto.rows[i];
					if (col.code == colCode) {
						// 给选择框设置的字段赋值
						domForm.find('input[name="' + colCode + '"]').val(rowSelected[col.modalValueCode]);
						domForm.find('input[name="' + colCode + '"]').trigger("propertychange");
					} else if(col.modalRelativeCode == colCode) {
						domForm.find('input[name="' + col.code + '"]').val(rowSelected[col.modalValueCode]);
						domForm.find('input[name="' + col.code + '"]').trigger("propertychange");
					}
				}
			},
			matchValuesAfterModalSelectCheckbox:function (rowSelected, extraData) { // 复选框选中数据后，匹配表单数值
				var t = this;
				var domForm = $('#' + t.c.id_form);

				for(var i = 0; i < t.c.dto.rows.length; i++){
					var col = t.c.dto.rows[i];
					if (col.code == colCode) {
						// 给选择框设置的字段赋值
						domForm.find('input[name="' + colCode + '"]').val(rowSelected[col.modalValueCode]);
					} else if(col.modalRelativeCode == colCode) {
						domForm.find('input[name="' + col.code + '"]').val(rowSelected[col.modalValueCode]);
					}
				}
			},
			getPanelSubId:function () {
				return this.c.id_panel_sub;
			},
			loadSubGrid: function() { // 初始化子表
				var t = this;
				if(t.c.subGridConfig) {
					if (t.c.subGridConfig.name == 'simple_table_TCW_RunningBack') {
						t.subGrid = layui.simple_table_TCW_RunningBack.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TP_BoutiqueSiteDetail') {
                        t.subGrid = layui.simple_table_TP_BoutiqueSiteDetail.init(t.c.subGridConfig);
                    }else if (t.c.subGridConfig.name == 'simple_table_TP_ProductBq') {
                    	t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TP_ProductBq.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TP_ProductBqSp') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TP_ProductBqSp.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_THR_OperateRegistration') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_THR_OperateRegistration.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_TS_UserInfo_BatchChangeOrg') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TS_UserInfo_BatchChangeOrg.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_TS_OperateOrg_BatchChangeOrg') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TS_OperateOrg_BatchChangeOrg.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_TP_ProductActiveWD') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TP_ProductActiveWD.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_TCW_FinancesEventGroupsOp') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TCW_FinancesEventGroupsOp.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_WF_Store') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_WF_Store.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_TB_UserTaxManage') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_UserTaxManage.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_YS_Col_init_cols') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_YS_Col_init_cols.init(t.c.subGridConfig);
					} else if (t.c.subGridConfig.name == 'simple_table_TB_UserMonthPerformanceReport') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_UserMonthPerformanceReport.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TB_UserPayApply') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_UserPayApply.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TWL_StockBorrow') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TWL_StockBorrow.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_THR_CanvassApply') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_THR_CanvassApply.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_THR_OperateCompanyApply_ByArchives') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_THR_OperateCompanyApply_ByArchives.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TB_BaseinfoDwmc') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_BaseinfoDwmc.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TB_BaseinfoLmwh') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_BaseinfoLmwh.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TB_BaseinfoSpcz') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_BaseinfoSpcz.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TB_BaseinfoSppl') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_BaseinfoSppl.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TB_BaseinfoSppm') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_BaseinfoSppm.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TB_BaseinfoSpyt') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TB_BaseinfoSpyt.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TCC_LogisticsMethodSiteDetail') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TCC_LogisticsMethodSiteDetail.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TCC_LogisticsMethodSiteDetail') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TCC_LogisticsChannelMaintSiteDetail.init(t.c.subGridConfig);
					}else if (t.c.subGridConfig.name == 'simple_table_TCC_LogisticsChannelMaintSiteDetail') {
						t.c.subGridConfig.formObj = t;
						t.subGrid = layui.simple_table_TCC_LogisticsChannelMaintSiteDetail.init(t.c.subGridConfig);
					}

				}
				//this.subGrid = 
			},
			getSubData: function() { // 获取子表数据
				return this.subGrid.getData();
			},
			getSubData2: function() { // 获取子表数据
				return this.c.subGridObj.getData();
			},
			getFormElement: function(index) { // 获取表单子元素
				return $('#' + this.c.id_form).find('.layui-form-item').children().eq(index);
			},
			afterFormElement: function(index, html) { // 表单子元素追加元素
				return $('#' + this.c.id_form).find('.layui-form-item').children().eq(index).after(html);
			},
			getValueByName: function(name) {
				var value = $('#' + this.c.id_form).find('input[name="' + name + '"]').val();
				if(!value) {
					return $('#' + this.c.id_form).find('select[name="' + name + '"]').val();
				} else {
					return value;
				}
			},
			setValueByName: function(name, value) {
				$('#' + this.c.id_form).find('input[name="' + name + '"]').val(value);
			},
			init:function (c) {
				this.f(c);
				this.load();
				this.loadSubGrid();
				if(c.callback && typeof c.callback === 'function') {
					c.callback();
				}
				return object;
			}
		};
	exports('YsForm', object);
});

function ysFormRemoveFile(obj) {
	var domThis = $(obj);
	var labelName = domThis.attr('label');
	var domParent = domThis.parent();
	// 隐藏删除按钮
	domParent.find('button[data-event-name="remove-file"]').hide();
	// 隐藏下载按钮
	domParent.find('button[data-event-name="download-file"]').hide();
	
	// 表单值清空
	domParent.find('input[name="' + labelName + '"]').val('');
	
	// 图标恢复上传前
	domParent.find('img').attr('src', '/static/img/img_add.jpg');
}

function ysFormDownloadFile(obj) {
	var domThis = $(obj);
	var labelName = domThis.attr('label');
	var domParent = domThis.parent();
	window.open(domParent.find('input[name="' + labelName + '"]').val());
}